package com.vlefen.springcloud.grpc.config;

import com.vlefen.springcloud.grpc.grpc.StubFactory;
import com.vlefen.springcloud.grpc.spring.GRpcAutowiredAnnotationBeanPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class GRpcClientAutoConfiguration {

    @Bean
    public GRpcAutowiredAnnotationBeanPostProcessor autowiredAnnotationBeanPostProcessor(ApplicationContext context, StubFactory stubFactory) {
        return new GRpcAutowiredAnnotationBeanPostProcessor(context, stubFactory);
    }


    @Bean
    @ConditionalOnMissingBean
    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    public StubFactory stubFactory(GRpcProperties gRpcProperties) {
        return new StubFactory(gRpcProperties);
    }


}
